<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1 , user-scalable=no">
<title>学院添加</title>
<link href="__PUBLIC__/plugins/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-dashen.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/font-awesome.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/animate.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
</head>
<body style="margin-top:70px;">
{include file="common/header" /}
<div class="container">
	<div class="row">
		<div class="col-md-12 wow fadeInUp" data-wow-duration="0.5s">
			<div>
				<!-- Nav tabs -->
				<ul class="nav nav-tabs" role="tablist">
			    	<li role="presentation" ><a href="{:url('College/frontlist')}">学院列表</a></li>
			    	<li role="presentation" class="active"><a href="#collegeAdd" aria-controls="collegeAdd" role="tab" data-toggle="tab">添加学院</a></li>
				</ul>
				<!-- Tab panes -->
				<div class="tab-content">
				    <div role="tabpanel" class="tab-pane" id="collegeList">
				    </div>
				    <div role="tabpanel" class="tab-pane active" id="collegeAdd"> 
				      	<form class="form-horizontal" name="collegeAddForm" id="collegeAddForm" enctype="multipart/form-data" method="post"  class="mar_t15">
						  <div class="form-group">
							 <label for="college_collegeNumber" class="col-md-2 text-right">学院编号:</label>
							 <div class="col-md-8"> 
							 	<input type="text" id="college_collegeNumber" name="college_collegeNumber" class="form-control" placeholder="请输入学院编号">
							 </div>
						  </div> 
						  <div class="form-group">
						  	 <label for="college_collegeName" class="col-md-2 text-right">学院名称:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="college_collegeName" name="college_collegeName" class="form-control" placeholder="请输入学院名称">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="college_collegeBirthDateDiv" class="col-md-2 text-right">成立日期:</label>
						  	 <div class="col-md-8">
				                <div id="college_collegeBirthDateDiv" class="input-group date college_collegeBirthDate col-md-12" data-link-field="college_collegeBirthDate" data-link-format="yyyy-mm-dd">
				                    <input class="form-control" id="college_collegeBirthDate" name="college_collegeBirthDate" size="16" type="text" value="" placeholder="请选择成立日期" readonly>
				                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
				                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				                </div>
						  	 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="college_collegeMan" class="col-md-2 text-right">院长姓名:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="college_collegeMan" name="college_collegeMan" class="form-control" placeholder="请输入院长姓名">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="college_collegeTelephone" class="col-md-2 text-right">联系电话:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="college_collegeTelephone" name="college_collegeTelephone" class="form-control" placeholder="请输入联系电话">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="college_collegeMemo" class="col-md-2 text-right">附加信息:</label>
						  	 <div class="col-md-8">
							    <textarea id="college_collegeMemo" name="college_collegeMemo" rows="8" class="form-control" placeholder="请输入附加信息"></textarea>
							 </div>
						  </div>
				          <div class="form-group">
				             <span class="col-md-2"></span>
				             <span onclick="ajaxCollegeAdd();" class="btn btn-primary bottom5 top5">添加</span>
				          </div>
						</form> 
				        <style>#collegeAddForm .form-group {margin:10px;}  </style>
					</div>
				</div>
			</div>
		</div>
	</div> 
</div>

{include file="common/footer" /}
<script src="__PUBLIC__/plugins/jquery.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrap.js"></script>
<script src="__PUBLIC__/plugins/wow.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugins/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="__PUBLIC__/plugins/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script>
	//提交添加学院信息
	function ajaxCollegeAdd() { 
		//提交之前先验证表单
		$("#collegeAddForm").data('bootstrapValidator').validate();
		if(!$("#collegeAddForm").data('bootstrapValidator').isValid()){
			return;
		}
		jQuery.ajax({
			type : "post",
			url : "{:url('College/frontAdd')}",
			dataType : "json" , 
			data: new FormData($("#collegeAddForm")[0]),
			success : function(obj) {
				if(obj.success){ 
					alert("保存成功！");
					$("#collegeAddForm").find("input").val("");
					$("#collegeAddForm").find("textarea").val("");
				} else {
					alert(obj.message);
				}
			},
			processData: false, 
			contentType: false, 
		});
	} 
$(function(){
	/*小屏幕导航点击关闭菜单*/
    $('.navbar-collapse a').click(function(){
        $('.navbar-collapse').collapse('hide');
    });
    new WOW().init();
	//验证学院添加表单字段
	$('#collegeAddForm').bootstrapValidator({
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		},
		fields: {
			"college_collegeNumber": {
				validators: {
					notEmpty: {
						message: "学院编号不能为空",
					}
				}
			},
			"college_collegeName": {
				validators: {
					notEmpty: {
						message: "学院名称不能为空",
					}
				}
			},
			"college_collegeBirthDate": {
				validators: {
					notEmpty: {
						message: "成立日期不能为空",
					}
				}
			},
		}
	}); 
	//成立日期组件
	$('#college_collegeBirthDateDiv').datetimepicker({
		language:  'zh-CN',  //显示语言
		format: 'yyyy-mm-dd',
		minView: 2,
		weekStart: 1,
		todayBtn:  1,
		autoclose: 1,
		minuteStep: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0
	}).on('hide',function(e) {
		//下面这行代码解决日期组件改变日期后不验证的问题
		$('#collegeAddForm').data('bootstrapValidator').updateStatus('college_collegeBirthDate', 'NOT_VALIDATED',null).validateField('college_collegeBirthDate');
	});
})
</script>
</body>
</html>
